const app = getApp()
import http from "../../utils/request.js";
const publicFun = require('../../utils/public');

Page({
    /**
     * 页面的初始数据
     */
    data: {
        height: 0,
        currImg: 'https://meng-1320327905.cos.ap-shanghai.myqcloud.com/2024-02-18/bg7_compressed.webp',
        imgList: [
            'https://meng-1320327905.cos.ap-shanghai.myqcloud.com/2024-02-18/bg1_compressed.webp',
            'https://meng-1320327905.cos.ap-shanghai.myqcloud.com/2024-02-18/bg2_compressed.webp',
            'https://meng-1320327905.cos.ap-shanghai.myqcloud.com/2024-02-18/bg6_compressed.webp',
            'https://meng-1320327905.cos.ap-shanghai.myqcloud.com/2024-02-18/bg7_compressed.webp',
        ],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            height: wx.getSystemInfoSync().windowHeight
        })
        if (options.edit) {
            app.globalData.vip = true
        } else {
            app.globalData.vip = false
        }
        this.getImg()
    },

    getImg() {
        let a = Math.random();
        let b = a * 4
        let c = Math.floor(b)
        this.setData({
            currImg: this.data.imgList[c]
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        // this.AIchat()
    },

    // 点击进入
    enter() {
        wx.switchTab({
            url: '/page/index/index',
        })
    },

    //用户授权
    auth(e) {
        if (!app.globalData.openid) {
            app.login()
        } else {
            app.getSysUser()
        }
    },



    //AI聊天测试
    AIchat() {
        let data = {
            question: '你是谁？'
        }
        http.Request({
            url: 'wxChatV2',
            method: 'POST',
            data: data,
        }).then(res => {
            if (res.code == 200) {
                console.log(res.data.data);
            }
        });
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
        return {
            title: '梦萦记',
            path: 'page/load/load'
        }
    }
})